package com.myfb.antstorm.authserver.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Auther: yiwenhu
 * @Date: 2019-02-26 上午 9:57
 * @Description:
 */
@Controller
public class UserInfoController {

//    @GetMapping("/login")
//    public String login(){
//        return "login";
//    }
//    @PostMapping("/login")
//    public String loginIn(){
//        return "index";
//    }
//    @PostMapping("/uaa/login")
//    @ResponseBody
//    public String loginIn(){
//        return "index";
//    }
//    @GetMapping("/")
//    public String index(){
//        return "index";
//    }
    @GetMapping("/uaa/user")
    @ResponseBody
    public Principal user(Principal user){
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        return user;
    }

//    @GetMapping("/uaa/user")
//    @ResponseBody
//    public Authentication getUser(Authentication authentication) {
//        return authentication;
//    }
}
